#include <bits/stdc++.h>
#define int long long
using namespace std;

int d[100005], v[100005], a[100005], p[100005];

signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for (int j = 1;j <= t;j++)
    {
        int n, m, L, V, jsq = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1;i <= n;i++)
        {
            cin >> d[i] >> v[i] >> a[i];
            int x = pow(v[i], 2) + 2 * (p[m] - d[i]) * a[i];
            v[i] = sqrt(x);
            if (v[i] > V) jsq++;
        }
        for (int i = 1;i <= m;i++)
       {
           cin >> p[i];
       }
       cout << jsq << " " << 1 << "\n";
    }
    return 0;
}
